#include<iostream>
#include<cstring>
using namespace std;
const int N = 2010;
bool st[N];
int t1, t2, t3, t4;
int n;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		memset(st, 0, sizeof(st));
		cin >> t1 >> t2 >> t3 >> t4;
		for (int i = t1; i <= t2; i++) {
			st[i] = 1;
		}
		for (int i = t3; i <= t4; i++) {
			st[i] = 1;
		}
		cin >> n;
		int x;
		int flag = 0;
		while (n--) {
			cin >> x;
			if (st[x]) {
				flag++;
			}
		}
		if (flag) {
			cout << "Y" << endl;
		}
		else {
			cout << "N" << endl;
		}
	}
	return 0;
}